
--Insert model
INSERT INTO r_workflow_model (r_wkf_mdl_id, t_ref_wkf_type_id, r_wkf_mdl_name, r_wkf_mdl_desc, r_wkf_mdl_assembly, r_wkf_mdl_classname, r_wkf_mdl_rules, r_wkf_mdl_system, r_wkf_mdl_enabled) VALUES (6, 1, N'Workflow de validation de Facture CAMPARI', N'Workflow de validation de Facture CAMPARI', N'Rio.Workflow.Campari.Invoicing', N'Invoicing', N'<?xml version="1.0"?>
<Rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" UseGlobalActionOnly="false">
  <WkfStates>
    <WkfState Value="Started">
      <Actions>
        <Action Identifier="2000" UiTypeAction="Validate" ValidatingMode="One">
          <Conditions>
            <Condition Target="Document" IsFinalState="false" StateMode="One" NewState="Validated" />
            <Condition Target="Workflow" IsFinalState="true" NewState="Validated">
              <If>
                <States>
                  <State Target="Document" StateMode="All" Value="Validated" />
                </States>
              </If>
            </Condition>
          </Conditions>
        </Action>
        <Action Identifier="2001" UiTypeAction="Refuse" >
          <Conditions>
            <Condition Target="Document" IsFinalState="true" StateMode="One" NewState="Rejected" />
            <Condition Target="Workflow" IsFinalState="true" NewState="Rejected" />
          </Conditions>
        </Action>
        <Action Identifier="0" UiTypeAction="Revive" IsOption="true" IsSenderOnly="true"/>
      </Actions>
    </WkfState>
    <WkfState Value="Validated">
      <Actions>
        <Action Identifier="0" UiTypeAction="Index" IsOption="true" />
      </Actions>
    </WkfState>
    <WkfState Value="Rejected">
      <Actions>
        <Action Identifier="1000" UiTypeAction="Ventilate" IsSenderOnly="true"/>
        <Action Identifier="0" UiTypeAction="Index" IsOption="true" />
      </Actions>
    </WkfState>
  </WkfStates>
</Rules>', 1, 1);

--Insert actions
INSERT INTO T_REF_WORKFLOW_ACT_COND (t_ref_wkf_act_cond_id, t_ref_wkf_act_cond_name, t_ref_wkf_act_cond_desc, t_ref_wkf_class_name, t_ref_wkf_assembly, t_ref_wkf_act_cond_is_cond) VALUES (2000, N'Valider', N'Valider le document', N'ValidateAction', N'Rio.Workflow.Campari.Invoicing', 0);
INSERT INTO T_REF_WORKFLOW_ACT_COND (t_ref_wkf_act_cond_id, t_ref_wkf_act_cond_name, t_ref_wkf_act_cond_desc, t_ref_wkf_class_name, t_ref_wkf_assembly, t_ref_wkf_act_cond_is_cond) VALUES (2001, N'Refuser', N'Refuser le document', N'RejectAction', N'Rio.Workflow.Campari.Invoicing', 0);

--Insert model actions ref
INSERT INTO r_workflow_model_act_cond (t_ref_wkf_act_cond_id, r_wkf_mdl_id) VALUES (2000, 6);
INSERT INTO r_workflow_model_act_cond (t_ref_wkf_act_cond_id, r_wkf_mdl_id) VALUES (2001, 6);
INSERT INTO r_workflow_model_act_cond (t_ref_wkf_act_cond_id, r_wkf_mdl_id) VALUES (7, 6);
INSERT INTO r_workflow_model_act_cond (t_ref_wkf_act_cond_id, r_wkf_mdl_id) VALUES (1, 6);
INSERT INTO r_workflow_model_act_cond (t_ref_wkf_act_cond_id, r_wkf_mdl_id) VALUES (16, 6);